package com.example.wn.common.exception;

import com.example.wn.model.vo.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/*
统一异常处理类
 */
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return Result.build(null, 201, "出现异常");
    }

    @ExceptionHandler(WeiNongException.class)
    @ResponseBody
    public Result error(WeiNongException e){
        e.printStackTrace();
        return Result.build(null, e.getResultCodeEnum());
    }
}
